<template>
  <div>
    <dt-modal-info ref="editRef" title="查看功能包权限">
      <div>功能包名称：{{ infoVal.title }}</div>
      <div style="max-height: 400px; overflow: auto">
        <div>功能包权限：</div>
        <Tree :data="permissionData" ref="treeRef" :select-node="false"></Tree>
        <dt-loading ref="loadingRef" :loading="loading"></dt-loading>
      </div>
    </dt-modal-info>
  </div>
</template>
<script setup>
  import { ref } from 'vue'
  import dt from '@dt/dt'
  import apiMgr from '../biz/index.js'
  const editRef = ref()
  const loading = ref(false)
  const permissionData = ref([])
  const infoVal = ref({})
  function getPermissionData() {
    // 权限树数据
    let params = {
      id: infoVal.value.id
    }
    loading.value = true
    apiMgr
      .getPackageAuthById(params)
      .then((res) => {
        permissionData.value = res
        loading.value = false
      })
      .catch((err) => {
        loading.value = false
      })
  }
  function show(id, title) {
    infoVal.value.id = id
    infoVal.value.title = title
    editRef.value.show()
    getPermissionData()
  }
  defineExpose({ show })
</script>
